#include "AccountManager.h"
#include "BCSManager.h"
#include <sstream>

#include <jni.h>
#include "platform/android/jni/JniHelper.h"
#include "Misc.h"

USING_NS_CC;

extern "C" {

	static bool getJavaEnv(JNIEnv **env)
	{
		bool bRet = false;

		do 
		{
			if (JniHelper::getJavaVM()->GetEnv((void**)env, JNI_VERSION_1_4) != JNI_OK)
			{
				break;
			}

			if (JniHelper::getJavaVM()->AttachCurrentThread(env, 0) < 0)
			{
				break;
			}

			bRet = true;
		} while (0);        

		return bRet;
	}

	void login_c()
	{
		JniMethodInfo t;
		if (JniHelper::getStaticMethodInfo(t, "org/gzy/xiaolian/AccountManager", "login", "()V")) {

			t.env->CallStaticVoidMethod(t.classID, t.methodID);

			t.env->DeleteLocalRef(t.classID);
		}
	}
	void inputName_c()
	{
		JniMethodInfo t;
		if (JniHelper::getStaticMethodInfo(t, "org/gzy/xiaolian/AccountManager", "inputName", "()V")) {

			t.env->CallStaticVoidMethod(t.classID, t.methodID);

			t.env->DeleteLocalRef(t.classID);
		}
	}
}


std::string AccountManager::getUserName()
{
	return m_userName;
}

std::string AccountManager::getUserUin()
{
	return m_userUin;
}

void AccountManager::login()
{
	login_c();
}

void AccountManager::inputName()
{
	inputName_c();
}